import request from './request'

// 分页查询检录信息
export const getCheckinPage = (params) => {
  return request.get('/checkin/page', { params })
}

// 根据比赛项目ID查询检录信息
export const getCheckinByEventId = (eventId) => {
  return request.get(`/checkin/event/${eventId}`)
}

// 创建检录记录
export const createCheckinRecords = (eventId) => {
  return request.post(`/checkin/create/${eventId}`)
}

// 运动员检录
export const checkinAthlete = (data) => {
  return request.post('/checkin/checkin', data)
}

// 批量检录
export const batchCheckin = (checkinIds) => {
  return request.post('/checkin/batch-checkin', checkinIds)
}

// 标记缺席
export const markAbsent = (checkinId, notes) => {
  return request.post(`/checkin/absent/${checkinId}`, null, {
    params: { notes }
  })
}

// 取消检录
export const cancelCheckin = (checkinId) => {
  return request.post(`/checkin/cancel/${checkinId}`)
}

// 获取检录统计信息
export const getCheckinStatistics = (eventId) => {
  return request.get(`/checkin/statistics/${eventId}`)
}

// 查询未检录的运动员列表
export const getUncheckedAthletes = (eventId) => {
  return request.get(`/checkin/unchecked/${eventId}`)
}

// 验证运动员是否已检录
export const verifyCheckin = (athleteId, eventId) => {
  return request.get('/checkin/verify', {
    params: { athleteId, eventId }
  })
}

// 根据运动员和比赛查询检录记录
export const getCheckinByAthleteAndEvent = (athleteId, eventId) => {
  return request.get('/checkin/athlete-event', {
    params: { athleteId, eventId }
  })
}

// 删除检录记录
export const deleteCheckinRecord = (checkinId) => {
  return request.delete(`/checkin/${checkinId}`)
}
